﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Diagnostics;

namespace Brunch.Forms
{
    public partial class AboutForm : Form
    {
        public AboutForm()
        {
            InitializeComponent();

			lnkCodeplex.Links.Add(0, lnkCodeplex.Text.Length, lnkCodeplex.Text);
            lnkFatcow.Links.Add(9, 6, "http://www.fatcow.com/free-icons/");
            lnkCC2.Links.Add(11, 35, "http://creativecommons.org/licenses/by/3.0/us/");
			pictureBox1.Image = global::Brunch.Resources.arrow_branch_32x32;
			lblAppName.Text = string.Format("{0} v{1}", Constants.ProductName, Assembly.GetExecutingAssembly().GetName().Version.ToString());
            this.Text = "About " + Constants.ProductName;
        }

        public static void OpenUrl(string url)
        {
            try
            {
                System.Diagnostics.Process.Start(url, null);
            }
            catch (Exception ex)
            {
				Common.ShowError("Error opening link.\r\nError: " + ex.Message);
            }
        }

        private void OnLinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            var lnkLabel = sender as LinkLabel;
            if (lnkLabel != null)
            {
                lnkLabel.Links[lnkLabel.Links.IndexOf(e.Link)].Visited = true;
                string target = e.Link.LinkData as string;
                if (null != target)
                    OpenUrl(target);
            }
        }

    }
}
